package eu.easyedu.dictionary.api.model;

import eu.easyedu.persistence.annotations.Column;
import eu.easyedu.persistence.annotations.Entity;
import java.io.Serializable;

/**
 * @author hlavki
 * @version 1.0
 * @created 29-IX-2007 20:04:36
 */
@Entity(table = "LANGUAGE")
public class Language implements Serializable {

    private static final long serialVersionUID = 1L;
    @Column(name = "LANGUAGE_ID", uniqueName = true)
    private Long id;
    @Column(name = "NAME")
    private String name;
    /**
     * kod jazyka
     */
    @Column(name = "CODE")
    private String code;


    public Language() {
    }


    public Language(Long id) {
        this.id = id;
    }


    public Language(String code) {
        this.code = code;
    }


    public Language(Long id, String name) {
        this.id = id;
        this.name = name;
    }


    public Language(String code, String name) {
        this.code = code;
        this.name = name;
    }


    public String getCode() {
        return code;
    }


    public void setCode(String code) {
        this.code = code;
    }


    public Long getId() {
        return id;
    }


    public void setId(Long id) {
        this.id = id;
    }


    public String getName() {
        return name;
    }


    public void setName(String name) {
        this.name = name;
    }


    @Override
    public String toString() {
//        StringBuilder sb = new StringBuilder(this.getClass().getSimpleName());
//        sb.append(" [").append(getId()).append(" | ").append(getCode()).append(" | ").append(getName());
//        return sb.toString();
        return getName() + " (" + getCode() + ")";
    }


    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Language other = (Language) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }


    @Override
    public int hashCode() {
        int hash = 7;
        hash = 31 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }
}
